package com.yunxi.service.localService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.core.util.BeanTools;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.dao.order.OrderCustomerMapper;
import com.yunxi.hubToBiz.pojo.OrderActualSalesRespVO;
import com.yunxi.model.order.OrderCustomer;
import com.yunxi.order.pojo.*;
import com.yunxi.service.localService.OrderCustomerService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 零售订单 服务实现类
 * </p>
 *
 * @author
 * @since 2019-05-29
 */
@Service
public class OrderCustomerServiceImpl extends ServiceImplPlus<OrderCustomerMapper, OrderCustomer> implements OrderCustomerService {

   @Override
   public OrderCustomerVO load(String orderNo) {
      return baseMapper.load(orderNo);
   }

   @Override
   public PageInfo<OrderCustomerExOrderOemSaveReqVO> convertGroupList(Integer pageNum, Integer pageSize, String partnerCode) {
//      Map map = BeanTools.bean2map(orderCustomerVO);
      PageHelperPlus.startPage(pageNum, pageSize);
      List<OrderCustomerExOrderOemSaveReqVO> list = baseMapper.convertGroupList(partnerCode);
      PageInfo<OrderCustomerExOrderOemSaveReqVO> pageInfo = new PageInfo<OrderCustomerExOrderOemSaveReqVO>(list);
      return pageInfo;
   }

   @Override
   public List<String> getCustomerNo(OrderCustomerExOrderOemSaveReqVO v) {
      return baseMapper.getCustomerNo(v);
   }

   @Override
   public List<OrderCustomerVO> allList(OrderCustomerVO orderCustomerVO) throws Exception {
      return baseMapper.allList(orderCustomerVO);
   }

   @Override
   public String getCatalogNameByOrderId(String orderCustomerId) throws Exception {
      return baseMapper.getCatalogNameByOrderId(orderCustomerId);
   }

   @Override
   public void assignSaler(OrderCustomer orderCustomer) {
      baseMapper.assignSaler(orderCustomer);
   }

   @Override
   public void updateCancel(OrderCustomer oc) {
      baseMapper.updateCancel(oc);
   }

   @Override
   public void cancelApply(OrderCustomer oc) {
      baseMapper.cancelApply(oc);
   }

   @Override
   public List listAllByCustomerNo(OrderCustomerVO v) {
      return baseMapper.listAllByCustomerNo(v);
   }

   @Override
   public void unbindCar(OrderCustomer orderCustomer) {
      baseMapper.unbindCar(orderCustomer);
   }

   @Override
   public void assignPartner(OrderCustomerVO orderCustomerVO) {
      baseMapper.assignPartner(orderCustomerVO);

   }

   @Override
   public PageInfo<OrderCustomerVO> cancelPageWait(OrderCustomerVO v, Integer pageNum, Integer pageSize, LoginInfo loginInfo) {
      PageHelperPlus.startPage(pageNum, pageSize);
      Map map = BeanTools.bean2map(v);
      map.put("roleCode", loginInfo.getRoleCode());
      map.put("partnerCode", loginInfo.getPartnerCode());
      map.put("loginUserCode",loginInfo.getUserCode());
      List<OrderCustomerVO> list = baseMapper.cancelListWait(map);
      PageInfo<OrderCustomerVO> pageInfo = new PageInfo<OrderCustomerVO>(list);
      return pageInfo;
   }

   @Override
   public String findCustomPackName(String customPackCodeS) {

     return baseMapper.findCustomPackName(customPackCodeS);
   }

   @Override
   public List<OrderActualSalesRespVO> listByVinAndCity(OrderCustomerVO vo) {
      Map map = BeanTools.bean2map(vo);
      return baseMapper.listByVinAndCity(map);
   }

   @Override
   public ProductNameVO getNameByVO(String productCode) {
      return baseMapper.getNameByVO(productCode);
   }

   @Override
   public OrderCustomerVO getByOrderCustomerNo(String orderNo) {
      return baseMapper.getByOrderCustomerNo(orderNo);
   }

   @Override
   public String isDelivery(String orderCustomerNo) {
      return baseMapper.isDelivery(orderCustomerNo);
   }

   @Override
   public String isActualSales(String orderCustomerNo) {
      return baseMapper.isActualSales(orderCustomerNo);
   }

   @Override
   public void updateVinByOrderCutomerNo(String orderCustomerNo, String vin) {
      OrderCustomerVO vo = new OrderCustomerVO();
      vo.setOrderCustomerNo(orderCustomerNo);
      vo.setVin(vin);
      baseMapper.updateVinByOrderCutomerNo(vo);
   }

   @Override
   public void assignBatch(List<OrderCustomer> orderCustomerList) {
      baseMapper.assignBatch(orderCustomerList);
   }

   @Override
   public void updateVin(String vin) {
      baseMapper.updateVin(vin);
   }

   @Override
   public void updateByOrderCustomerNo(String orderCustomerNo) {
      baseMapper.updateByOrderCustomerNo(orderCustomerNo);
   }

   @Override
   public OrderCustomerVO getByVin(String vin) {
      return baseMapper.getByVin(vin);
   }

   @Override
   public void cancel(OrderCustomer oc) {
      baseMapper.cancel(oc);
   }

    @Override
    public List<OrderCustomerExportVO> exportOrder(OrderCustomerVO orderCustomerVO) {
       return baseMapper.exportOrder(orderCustomerVO);
    }
}
